package com.springboot.demo.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.springboot.demo.pojo.user;
import com.springboot.demo.service.UserService;

@RestController
@RequestMapping("/user")
@PropertySource(value= {"classpath:application.properties"})
public class UserController {
	@Autowired
	private UserService userService;
	
	@GetMapping("/login")
	public user login(@RequestParam("name")String name,@RequestParam("password")String password) {
		
		user u = new user();
		u.setUserName(name);
		u.setPassword(password);
		user selectByPrimaryKey = userService.selectByPrimaryKey(1);
		return selectByPrimaryKey;
	}
	
	@Value("${server.port}")
	private String name;
	@GetMapping("test")
	public String test() {
		return name;
	}
	

}
